import request from '@/utils/request'

export default {
    // 获取信息
    getList(query, current = 1, size = 20) {
        return request({
            url: '/system/role/search',
            method: 'post',
            data: {
                ...query,
                current,
                size
            }

        })
    },
    // 增加角色
    add(data) {
        return request({
            url: '/system/role',
            method: 'post',
            data: data

        })
    },
    // 通过id查询
    getById(id) {
        return request({
            url: `/system/role/${id}`,
            method: 'get',
        })
    },
    // 更新数据
    update(data) {
        return request({
            url: `/system/role`,
            method: 'put',
            data: data
        })
    },
    // 根据ID删除
    deleteById(id) {
        return request({
            url: `/system/role/${id}`,
            method: 'delete',

        })
    },
    // 获取指定角色id所拥有的权限菜单ids
    getMenuIdsByRoleId(id) {
        return request({
            url: `/system/role/${id}/menu/ids`,
            method: 'get',

        })
    },
    // 新增角色权限
    saveRoleMenu(id, menuIds) {
        return request({
            url: `/system/role/${id}/menu/save`,
            method: 'post',
            data: menuIds

        })
    }
}